package rs.mbs2.epics.server.servlet;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import rs.mbs2.epics.server.entity.Album;
import rs.mbs2.epics.server.session.dao.localinterface.AlbumDaoLocal;

@SuppressWarnings("serial")
public class PreChangeAlbumController extends HttpServlet {


	@EJB
	AlbumDaoLocal albumDao;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String id = (String) request.getParameter("id");
		Integer albumId = Integer.parseInt(id);
		Album album = albumDao.findById(albumId);
		request.setAttribute("album", album);
		request.getRequestDispatcher("/changeAlbum.jsp").forward(request, response);
	}


	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}


}
